package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.api.foundations.dto.response.RegionSimpleResDTO;
import com.jzo2o.foundations.service.IRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController("consumerRegionController")
@RequestMapping("/consumer/region")
@Api(tags = "用户端 - 区域相关接口")
public class RegionController {
    @Resource
    private IRegionService regionService;
    @GetMapping("activeRegionList")
    @ApiOperation("已开通服务区域列表")
    public List<RegionSimpleResDTO> activeRegiolist(){
        return regionService.queryActiveRegionListCache();
    }

    @PutMapping("activate/{id}")
    @ApiOperation("区域启动")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "区域id",required = true,dataTypeClass = Long.class)
    })
    public void activate(@PathVariable("id") Long id){
        regionService.active(id);
    }
    @PutMapping("/deactivate/{id}")
    @ApiOperation("区域禁用")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "区域id",required = true,dataTypeClass = Long.class)
    })
    public void deactivate(@PathVariable("id")Long id){
        regionService.deactivate(id);
    }




}
